﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignDemo
{
    class WeaponSystem
    {
        string name;
        List<IWeaponSystemPart> parts = new List<IWeaponSystemPart>();

        public WeaponSystem(string name)
        {
            this.name = name;
        }

        public void AddPart(IWeaponSystemPart part)
        {
            parts.Add(part);
        }

        public void Fire()
        {
            Console.BackgroundColor = ConsoleColor.Red;
            Console.WriteLine("Firing " + name);
            Console.BackgroundColor = ConsoleColor.Black;
            for (int i = 0; i < parts.Count; i++)
            {
                parts[i].ActionOnFire();
            }
        }

        public void Reload()
        {
            Console.BackgroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine("Reloading " + name);
            Console.BackgroundColor = ConsoleColor.Black;
            for (int i = 0; i < parts.Count; i++)
            {
                parts[i].ActionOnReload();
            }
        }

        public void Update()
        {
            Console.BackgroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("Updating " + name);
            Console.BackgroundColor = ConsoleColor.Black;
            for (int i = 0; i < parts.Count; i++)
            {
                parts[i].Update();
            }
        }
    }
}
